package object

import (
	"time"
)

// MemberInfo 会员基本信息
type MemberInfo struct {
	// 品牌id
	BrandId int64
	// 用户id
	MemberId int64
	// 昵称
	Nickname string
	// 手机号
	Mobile string
	// 邮箱
	Email string
	// 性别
	Gender string
	// 省
	Province string
	// 城市
	City string
	// 国家码
	CountryCode string
	// 生日
	Birthday time.Time
}

func NewMemberInfo(brandId, memberId int64, nickname, mobile, email, gender, countryCode, province, city string, birthday time.Time) *MemberInfo {
	return &MemberInfo{
		BrandId:     brandId,
		MemberId:    memberId,
		Nickname:    nickname,
		Mobile:      mobile,
		Email:       email,
		Gender:      gender,
		Province:    province,
		City:        city,
		Birthday:    birthday,
		CountryCode: countryCode,
	}
}

// LoginChannelInfo 渠道信息
type LoginChannelInfo struct {
	// 品牌id
	BrandId int64
	// 用户id
	MemberId int64
	// 应用 openid
	OpenId string
	// unionid
	UnionId string
	// app 应用id
	AppId string
	// channel
	Channel string
	// 昵称
	Nickname string
	// 头像
	Avatar string
}

// NewLoginChannelInfo 新建渠道信息
func NewLoginChannelInfo(brandId, memberId int64, openId, appId, unionId, nickname, avatar, channel string) *LoginChannelInfo {
	return &LoginChannelInfo{
		BrandId:  brandId,
		MemberId: memberId,
		OpenId:   openId,
		AppId:    appId,
		UnionId:  unionId,
		Channel:  channel,
		Nickname: nickname,
		Avatar:   avatar,
	}
}

// MemberWithChannel 用户渠道信息聚合
type MemberWithChannel struct {
	// 会员id
	MemberId int64
	// 品牌id
	BrandId int64
	// 应用 openid
	OpenId string
	// app 应用id
	AppId string
	// 生日
	Birthday time.Time
	// 手机号
	Mobile string
	// 邮箱
	Email string
	// 昵称
	Nickname string
	// 头像
	Avatar string
	// 是否是会员
	IsFormal bool
}

// NewMemberWithChannel 新建对象
func NewMemberWithChannel(memberId, brandId int64, openId, appId, mobile, email, nickname, avatar string,
	isFormal bool, birthday time.Time) *MemberWithChannel {
	return &MemberWithChannel{
		MemberId: memberId,
		BrandId:  brandId,
		OpenId:   openId,
		AppId:    appId,
		Birthday: birthday,
		Mobile:   mobile,
		Email:    email,
		Nickname: nickname,
		Avatar:   avatar,
		IsFormal: isFormal,
	}
}

// MemberAccAgg 会员账号信息聚合
type MemberAccAgg struct {
	// 账号id
	AccId int64 `json:"acc_id"`
	// 会员id
	MemberId int64 `json:"member_id"`
	// 体系id
	GroupId int64 `json:"group_id"`
	// 卡id
	CardId int64 `json:"card_id"`
	// 卡名
	CardName string `json:"card_name"`
	// 卡封面
	Cover string `json:"cover"`
	// 是否可以充值
	CanRecharge bool `json:"can_recharge"`
	// 起充金额分
	TopupLimit uint64 `json:"topup_limit"`
	// 是否可以积分
	CanIntegral bool `json:"can_integral"`
	// 积分规则, 多少金额积一分
	UnitIntegralAmount uint64 `json:"unit_integral_amount"`
	// 余额
	Balance uint64 `json:"balance"`
	// 积分
	Integral uint64 `json:"integral"`
	// 折扣
	Discount uint64 `json:"discount"`
	// 押金
	Deposit uint64 `json:"deposit"`
}

func NewMemberAccAgg(accId, memberId, groupId, cardId int64, balance, integral, deposit uint64) *MemberAccAgg {
	return &MemberAccAgg{
		AccId:    accId,
		MemberId: memberId,
		GroupId:  groupId,
		CardId:   cardId,
		Balance:  balance,
		Integral: integral,
		Deposit:  deposit,
	}
}

func (acc *MemberAccAgg) SetCardInfo(cardName, cover string, canRecharge, canIntegral bool, topupLimit, unitIntegral, discount uint64) {
	acc.CardName = cardName
	acc.Cover = cover
	acc.CanRecharge = canRecharge
	acc.TopupLimit = topupLimit
	acc.CanIntegral = canIntegral
	acc.UnitIntegralAmount = unitIntegral
	acc.Discount = discount
}

// AdminMemberForList 后台会员列表信息
type AdminMemberForList struct {
	// 会员id
	MemberId int64 `json:"member_id" sql:"member_id"`
	// 品牌id
	BrandId int64 `json:"brand_id" sql:"brand_id"`
	// 昵称
	Nickname string `json:"nickname" sql:"nickname"`
	// 手机号
	Mobile string `json:"mobile" sql:"mobile"`
	// 账号id
	AccId int64 `json:"acc_id" sql:"acc_id"`
	// 卡id
	CardId int64 `json:"card_id" sql:"card_id"`
	// 卡名
	CardName string `json:"card_name" sql:"card_name"`
	// 余额
	Balance int64 `json:"balance" sql:"balance"`
	// 积分
	Integral int64 `json:"integral" sql:"integral"`
	// 注册时间
	CreatedAt time.Time `json:"created_at" sql:"created_at"`
}

// AdminMemberStatistic 后台用户数据统计
type AdminMemberStatistic struct {
	// 品牌id
	BrandId int64 `json:"brand_id"`
	// 今日之前用户总数
	HistoryRegisterNum uint32 `json:"history_register_num"`
	// 今日之前持卡用户数
	HistorySendCardNum uint32 `json:"history_send_card_num"`
	// 今日新增用户数
	TodayRegisterNum uint32 `json:"today_register_num"`
	// 今日新增持卡数
	TodaySendCardNum uint32 `json:"today_send_card_num"`
}
